<template>
<div class="goodsLsit-page">
    <div class="head">
        <div class="back" @click="back">
            <img src="../../assets/image/ic_back_black.png" alt="">
        </div>
        <div class="title">商品列表</div>
    </div>
    <div class="list-box" v-if="this.goodsList.length!=0">
        <div class="goods-box" @click="goodsDetail(item)" v-for="(item,index) in goodsList" :key="index">
            <div class="goods-left">
                <img :src="Config_ysy.img_url +item.images[0]" alt="">
            </div>
            <div class="goods-right">
                <div class="goods-title">{{item.goods_name}}</div>
                <div class="goods-price">{{item.spec[0].goods_price}}</div>
            </div>
        </div>
    </div>
     <div class="wu-content" v-else>
        <img src="../../assets/img/ss.png" alt="" />
        <p class="zw">暂无数据</p>
      </div>
</div>

</template>

<script>

import {orderList} from '../../sever/request'
export default {


    data() {
        return {
            goodsList:[],
            category_id:22,
            shop_id:'131',
            token:'123',
        }
    },

    mounted() {
        let store = this.$route.query;
        if (store.shop_id != undefined) {
                this.shop_id = store.shop_id;
        }
        if (store.token != "" && store.token != undefined) {
                this.token = store.token;
        }
        console.log("token",this.token);
        // this.token = uni.getStorageSync("userInfo").token;
        if(store.category_id!=undefined){
            this.category_id=store.category_id
        }
        this.getData()
    },
    created() {
    let store = this.$route.query;
    if (store.shop_id != undefined) {
      this.shop_id = store.shop_id;
    }
    if(store.category_id!=undefined){
            this.category_id=store.category_id
        }
    if (store.token != "" && store.token != undefined) {
      this.token = store.token;
    }
    },
    methods: {
        getData(){
            orderList({
                category_id:this.category_id,
                token:this.token
            }).then(res=>{
                this.goodsList=res.data.data
            })
        },
        goodsDetail(item){
            uni.navigateTo({
                url:'/pages/productDetail/productDetail?id='+ item.goods_id + '&type=1&goods_max_price='+item.spec[0].line_price+'&goods_min_price='+item.spec[0].goods_price
            })
            console.log(item)
  },
        back(){
            // uni.navigateBack();
          this.$router.go(-1)

        },
    },

}
</script>
<style lang="less" scoped>
.goodsLsit-page{
    width: 10rem;
    .head{
        width: 100%;
        height: 1.666667rem;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        background-color: #fff;
        padding-top: .933333rem;
        .back{
            margin-left: .4rem;
            img{
                width: .4rem;
                height: .5rem;
            }
        }
        .title{
            font-size: .45rem;
            color: #333;
            font-weight: bold;
            margin-left: 3.6rem;
            padding-top: .133333rem;
        }
    }
    .list-box{
        margin: .4rem .266667rem 0 .266667rem;
        .goods-box{
            width: 9.466667rem;
            background-color: #fff;
            border-radius: .266667rem;
            display: flex;
            justify-content: flex-start;
            margin-bottom: .266667rem;
            .goods-left{
                width: 2.666667rem;
                height: 2.666667rem;
                padding: .133333rem 0 .133333rem .133333rem;
                border-radius: .133333rem;
                img{
                    width: 2.666667rem;
                height: 2.666667rem;
                border-radius: .133333rem;
                }
            }
            .goods-right{
                 margin-left: .466667rem;
                 padding: .133333rem 0;
                 .goods-title{
                      width: 5.333333rem;
                      height: .6rem;
                      margin-top: .3rem;
                      line-height: .6rem;
                      font-size: .4rem;
                      font-weight: bold;
                      color: #333;
                       overflow: hidden; /*超出部分隐藏*/
                       white-space: nowrap; /*不换行*/
                      text-overflow: ellipsis; /*超出部分文字以...显示*/
                 }
                 .goods-price{
                     margin-top: .933333rem;
                     font-size: .346667rem;
                     color: rgb(241, 30, 30);
                     font-weight: 500;
                 }
            }
        }
    }
    .wu-content {
      margin: 6rem 4.266667rem 0 3.866667rem;
      text-align: center;
      img {
        width: 2rem;
        height: 2rem;
      }
      .zw {
        font-size: 0.32rem;
        color: #ccc;
        padding-top: 0.5rem;
        padding-left: 0.3rem;
      }
    }
}
</style>